// 获取到所有的复选框
// let goods = document.querySelectorAll("input[type=checkbox]:not(#all)");
let goods = document.querySelectorAll("input[name=item]");
let all = document.querySelector("#all");

function selectAll() {
    console.log("全选");
    for (let good of goods) {
        good.checked = all.checked;
        // good.checked = true;
    }

}

function reverseSelect() {
    for (let good of goods) {
        good.checked = !good.checked;
        // good.checked = true;
    }
    checkSelected();
}

function checkSelected() {
    for (let good of goods) {
        if (!good.checked) {
            all.checked = false;
            return;
        }
    }

    all.checked = true;
}

function total() {
    let total = 0.0;
    for (let item of goods) {
        if (item.checked) {
            total += parseFloat(item.value);
        }
    }
    document.querySelector("#total").innerHTML = total.toFixed(2);
    ;
}